package com.zyd.blog.homeart.service.impl;

import com.zyd.blog.persistence.beans.ReportContent;
import com.zyd.blog.persistence.beans.ReportType;
import com.zyd.blog.persistence.beans.RotationChart;
import com.zyd.blog.persistence.mapper.ReportContentMapper;
import com.zyd.blog.persistence.mapper.RotationChartMapper;
import com.zyd.blog.homeart.service.IRotationChartService;
import com.zyd.blog.util.ServiceException;
import lombok.extern.slf4j.Slf4j;
import me.zhyd.oauth.utils.UuidUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author liusongqi
 * @since 2020-02-10
 */
@Slf4j
@Service
public class RotationChartServiceImpl implements IRotationChartService {
    private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    @Autowired
    private RotationChartMapper rotationChartMapper;
    @Autowired
    private ReportContentMapper reportContentMapper;
    @Override
    public List<RotationChart> index(){
        List<RotationChart> index;
        index = rotationChartMapper.index();
        return index;
    }

    @Override
    public List<ReportType> reportType() {
        return rotationChartMapper.reportType();
    }

    @Override
    public Integer addReport(ReportContent reportContent) {
        reportContent.setAddTime(sdf.format(System.currentTimeMillis()));
        reportContent.setId(UuidUtils.getUUID());
        return reportContentMapper.insert(reportContent);
    }
}
